/******************************************************************************
 * @File name   :      IMemberPackageDao.java
 *
 * @Author      :      JIZHANGS
 *
 * @Date        :      Jul 24, 2015
 *
 * @Copyright Notice: 
 * Copyright (c) 2015 Capgemini, Inc. All  Rights Reserved.
 * This software is published under the terms of the Capgemini Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------
 * Date                   Who         Version        Comments
 * Jul 24, 2015 12:33:55 PM        JIZHANGS     1.0            Initial Version
 *****************************************************************************/
package com.cap.bts.crmdp.dealer.purchase.dao;

import java.util.List;

import com.cap.bts.crmdp.dealer.activation.dto.ActivationQueryDto;
import com.cap.bts.crmdp.dealer.purchase.domain.MemberPackageInfo;
import com.cap.bts.crmdp.dealer.redemption.dto.MemberAndDealerInfoDto;
import com.cap.bts.crmdp.dealer.redemption.dto.MemberQueryDto;
import com.cap.bts.framework.common.dao.IBaseDao;
import com.cap.bts.framework.common.exception.AppException;

/**
 *
 */
public interface IMemberPackageDao extends IBaseDao<MemberPackageInfo, Long> {
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param mpi
     * @return
     * @throws AppException
     */
    public MemberPackageInfo addMemberPackageInfo(MemberPackageInfo mpi) throws AppException; 
    
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param mpi
     * @throws AppException
     */
    public void updateMemberPackageInfo(MemberPackageInfo mpi) throws AppException;
    
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param mpi
     * @return
     * @throws AppException
     */
    public MemberPackageInfo getUnPurchaseMemberPackageInfo(MemberPackageInfo mpi) throws AppException;
    
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param mpi
     * @return
     * @throws AppException
     */
    public MemberPackageInfo getPurchasedMemberPackageInfo(MemberPackageInfo mpi) throws AppException;
    
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param mpi
     * @return
     * @throws AppException
     */
    public MemberPackageInfo getCancelMemberPackageInfoMars(MemberPackageInfo mpi) throws AppException;
   
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param mpi
     * @throws AppException
     */
    public void updateMemberPackageInfoById(MemberPackageInfo mpi) throws AppException;
    
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param dto
     * @return
     * @throws AppException
     */
    List<Object[]> getPackageListByMember(MemberQueryDto dto) throws AppException;
    
    /**
     * @Date        :      2015年9月18日
     * @param dto
     * @return
     * @throws AppException
     */
    List<Object[]> getPackageListForReportByMember(MemberQueryDto dto) throws AppException;
    /**
     * @Date        :      2015年9月17日
     * @param dto
     * @return
     * @throws AppException
     */
    List<MemberAndDealerInfoDto> getDealerInfoDto() throws AppException;
    
    /**
     * @Date        :      2015年10月22日
     * @param id
     * @return
     * @throws AppException
     */
    List<MemberAndDealerInfoDto> getMemberAndDealerInfoDtoByMemberId(Long id) throws AppException;
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param dto
     * @return
     * @throws AppException
     */
    Boolean checkActivePackage(MemberQueryDto dto) throws AppException;
    
    /**
     * @Date        :      2015年9月17日
     * @param dto
     * @return
     * @throws AppException
     */
    Boolean checkPackage(MemberQueryDto dto) throws AppException;
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @param packageDefId
     * @return
     * @throws AppException
     */
    String getNonPhysicalCardNumber(Long packageDefId) throws AppException;
    
    /**
     * 
     * @Date        :      Aug 28, 2015
     * @return
     * @throws AppException
     */
    List<MemberPackageInfo> getAllActiveMemberPackageList() throws AppException;
    

    /**
     * 
     * @Date        :      Aug 28, 2015
     * @return
     * @throws AppException
     */
    List<MemberPackageInfo> getMemberPackageList(int status) throws AppException;

	/**
	 * 
	 * @Date        :      2015-8-3
	 * @param dto
	 * @return
	 * @throws AppException
	 */
    public MemberPackageInfo getMemberPackageInfoByActivationDto(ActivationQueryDto dto) throws AppException;
    
    /**
     * @Date        :      2015年8月19日
     * @param dto
     * @return
     * @throws AppException
     */
    public MemberPackageInfo checkPackageNumberByActivationDto(ActivationQueryDto dto) throws AppException;
    
    /**
     * @Date        :      2015年8月19日
     * @param dto
     * @return
     * @throws AppException
     */
    public MemberPackageInfo checkPackageNumberAndActivationCodeByActivationDto(ActivationQueryDto dto) throws AppException;
    /**
     * @Date        :      2015年9月5日
     * @param dealerId
     * @param memberId
     * @return
     * @throws AppException
     */
    public List<MemberPackageInfo> getMemberPackageInfoByActiveDealerIdAndActiveMemberId(Long dealerId, Long memberId) throws AppException;
    /**
     * @Date        :      2015年9月6日
     * @param memberPackageInfo
     * @throws AppException
     */
    public void updateMemberPackageInfoByMemberPackageInfo(MemberPackageInfo memberPackageInfo,Long newMemberId) throws AppException;
    
    /**
     * 通过卡生成批次取得卡信息列表(导出卡片使用)
     * @Date        :      Aug 28, 2015
     * @throws AppException
     */
    public List<MemberPackageInfo> getMemberPackageInfoListByBatchId(Long batchId) throws AppException;
   
    /**
     * 取得套餐已经购买使用的次数
     * @Date        :      Sep 23, 2015
     * @return
     * @throws AppException
     */
    public int getPackagePurchaseNum(Long dealerId,Long memberId,Long carId,Long packageDefId) throws AppException;
    
    /**
     * 取得套餐已经购买使用的次数(按packageCode分组)
     * @Date        :      Sep 23, 2015
     * @return
     * @throws AppException
     */
    public int getPackagePurchaseNumWithPackageCode(Long dealerId,Long memberId,Long carId,Long packageDefId) throws AppException;
    
    
    /**
     * 取得code相同的套餐的使用次数的总和
     * @Date        :      2015年11月18日
     * @param dealerId
     * @param memberId
     * @param carId
     * @param packageDefId
     * @return
     * @throws AppException
     */
    public int getPackagesPurchaseNumWithSamePackageCode(Long dealerId,Long memberId,Long carId,String code) throws AppException;
    /**
     * 判断同一套餐组中的最大购买次数是否相同
     * @Date        :      Sep 23, 2015
     * @return
     * @throws AppException
     */
    public int checkPackagePurchaseNumWithPackageCode(Long dealerId,Long memberId,Long carId,Long packageDefId) throws AppException;
    
    /**
     * 根据卡定义前缀取得最新的卡号
     * @Date        :      Oct 16, 2015
     * @param prefix
     * @return
     */
    public MemberPackageInfo getMaxMemberPackageInfoByNonPhysicalCardPrefix(String prefix)  throws AppException;
    
    /**
     * 根据卡定义前缀取得最新的卡号
     * @Date        :      Oct 16, 2015
     * @param prefix
     * @return
     */
    public MemberPackageInfo getMaxMemberPackageInfoByPhysicalCardPrefix(String prefix)  throws AppException;


    /**
     * 
     * @Date        :      Nov 4, 2015
     * @param memberId
     * @param carId
     * @return
     * @throws AppException
     */
    public List<Object[]> getPackageListForReportByMember(Long memberId, Long carId) throws AppException;

    /**
     * 
     * @Date        :      Nov 4, 2015
     * @param memberId
     * @param carId
     * @return
     * @throws AppException
     */
    public List<MemberAndDealerInfoDto> getMemberAndDealerInfoDtoByMARSIdAndDearId(Long dealerId, String marsMemberId)
			throws AppException;
    
    /**
     * 通过卡号取得卡信息
     * @Date        :      Nov 4, 2015
     * @param memberId
     * @param carId
     * @return
     * @throws AppException
     */
    public MemberPackageInfo getMemeberPackageInfoByPackageNumber(String packageNumber)
            throws AppException;
    
    /**
     * @return
     * @throws AppException
     */
    public List<String> getfileDataList()throws AppException;
    
    /**
     * @return
     * @throws AppException
     */
    public List<Object[]> getExpireCompanyInfoFromDealerRelMars() throws AppException;
    
    /**
     * 根据company获取其下面的过期套餐信息
     * @param company
     * @return
     * @throws AppException
     */
    List<String> getExpirePackagefileDataList(String company) throws AppException;
    
    /**
     * @param packageDefId
     * @return
     * @throws AppException
     */
    public List<Long> getcardDefIdByPackageDefId(Long packageDefId) throws AppException;
    
    /**
     * 获取所有已到过期时间但为激活状态的卡
     * 
     * @return
     * @throws AppException
     */
    public List<MemberPackageInfo> getAllActiveExpireMemberPackageList() throws AppException;
    
    /**
     * @return
     * @throws AppException
     */
    public List<Object[]> getActiveExpireMemberPackageList() throws AppException;
    
    /**
     * @param idList
     * @param status
     * @throws AppException
     */
    public void updatePackageStatusById(String idList,int status) throws AppException;
    
    /**
     * @param id
     * @throws AppException
     */
    public void updatePackageStatusById(Long id) throws AppException;
    
    
    public List<Object[]> getPackageStatusByMemberId(Long memberId) throws AppException;
    
    public void deleteGiftByMemberId(Long memberId) throws AppException;
}
